<?php
$seminar = $this->data->seminar;

// Selected programs
echo '<h3>' . text::getEscaped('registration-selectedPrograms') . '</h3>';
registrationHelper::printSelectedProgramList($this->data->selectedProgramList);

// Discounts
$isAdmin = $this->getAuthUser('is_admin');
echo '<h2>' . text::getEscaped('seminar-discounts') . '</h2>';
if ($this->data->socialDiscount || $this->data->isEarlyDiscountApplied || $isAdmin) {
    echo '<ul>';
    if ($isAdmin) {
    	echo '<li>';
    	echo '<em>' . text::getEscaped('registration-extra_discount') . '</em>';
    	echo '<p class="description">' . text::getEscaped('registration-extraDiscount-desc') . '</p>';
    	
    	$dialogUrl = '/user/registrationWizard/extraDiscountForm';
    	if (! $this->data->extraDiscountForm) {
    		echo html::popup($dialogUrl, text::get('registrationWizard-addExtraDiscount'));
    	}
    	else {
    		$discountPrice = format::price($this->data->extraDiscountForm['extra_discount'], $this->data->priceGroup['currency_code']);
    		html::displayTable(array(
    				text::get('registration-discountHeight') => html::popup($dialogUrl, $discountPrice),
    				text::get('registration-discountReason') => format::longText($this->data->extraDiscountForm['extra_discount_reason'])
    		), false, true, false);
    		
    		echo '<ul class="commandList">';
    		echo '<li class="cancelCommand">' . html::anchor('/user/registrationWizard/cancelExtraDiscount', text::get('registrationWizard-cancelThisDiscount')) . '</li>';
    		echo '</ul>';
    	}
    	echo '</li>';
    }
    if ($this->data->socialDiscount) {
        if ($this->data->socialDiscount['before_deadline_only'] && $this->data->isAfterDeadline) {
            echo  text::getEscaped('registrationWizard.tooLateForDiscount', format::date($this->data->seminar['registration_deadline']));
        }
        else {
            echo '<li>';
            echo '<em>' . text::getEscaped('seminar.socialDiscount') . '</em>';
            echo '<p class="description">' . text::getEscaped('seminar.socialDiscount-desc') . '</p>';

            echo '<table class="displayTable">';
            echo '<tbody>';

            echo '<tr>';
            echo '<th><label>' . text::getEscaped('seminar.discountAvailableForKarmayoga') . '</label></th>';
            echo '<td>' . format::boolean($this->data->socialDiscount['available_for_karmayoga']) . '</td>';
            echo '</tr>';

            echo '<tr>';
            echo '<th><label>' . text::getEscaped('seminar.discountHeightPercentage') . '</label></th>';
            echo '<td>' . $this->data->socialDiscount['percentage'] . ' %</td>';
            echo '</tr>';

            echo '</tbody>';
            echo '</table>';

            echo '<ul class="commandList">';
            if ($this->data->isSocialDiscountApplied) {
                echo '<li class="applyCommand">' . text::getEscaped('registrationWizard.discountIsApplied') . '</li>';
                echo '<li class="goCommand">' . html::anchor('/user/registrationWizard/cancelSocialDiscount', text::get('registrationWizard.doNotApplyThisDiscount')) . '</li>';
            }
            else {
                echo '<li class="goCommand">' . html::anchor('/user/registrationWizard/applySocialDiscount', text::get('registrationWizard.applyForThisDiscount')) . '</li>';
            }
            echo '</ul>';

            echo '</li>';
        }
    }

    if ($this->data->isEarlyDiscountApplied) {
        echo '<li style="margin-top: 1em">';
        echo '<em>' . text::getEscaped('seminar.earlyDiscount') . '</em>';
        echo '<p class="description">' . text::getEscaped('seminar.earlyDiscount-desc') . '</p>';
        ?>
        <table class="displayTable">
            <tbody>
                <tr>
                    <th><?php echo text::getEscaped('seminar.registration_deadline') ?></th>
                    <td><?php echo format::date($this->data->seminar['registration_deadline']) ?></td>
                </tr>
                <tr>
                    <th><?php echo text::getEscaped('seminar.chargeAppliesToKarmayoga') ?></th>
                    <td><?php echo format::boolean($this->data->earlyDiscount['applies_to_karmayoga']) ?></td>
                </tr>
                <tr>
                    <th><?php echo text::getEscaped('seminar.earlyDiscountPercentage') ?></th>
                    <td><?php echo $this->data->earlyDiscount['percentage'] ?> %</td>
                </tr>
            </tbody>
        </table>
        <?php
        echo '</li>';
    }
    echo '</ul>';
}
else {
    echo '<p class="description">' . text::getEscaped('registrationWizard.noDiscountsAvailable') . '</p>';
}

// Extra charges
if ($this->data->isLateChargeApplied) {
	echo '<h2>' . text::getEscaped('seminar-extraCharges') . '</h2>';
	echo '<ul>';
	if ($this->data->isLateChargeApplied) {
		echo '<li style="margin-top: 1em">';
		echo '<em>' . text::getEscaped('seminar-lateCharge') . '</em>';
		echo '<p class="description">' . text::getEscaped('seminar-lateCharge-desc') . '</p>';
		?>
	        <table class="displayTable">
	            <tbody>
	                <tr>
	                    <th><?php echo text::getEscaped('seminar-registration_deadline') ?></th>
	                    <td><?php echo format::date($this->data->seminar['registration_deadline']) ?></td>
	                </tr>
	                <tr>
	                    <th><?php echo text::getEscaped('seminar-chargeAppliesToKarmayoga') ?></th>
	                    <td><?php echo format::boolean($this->data->lateCharge['applies_to_karmayoga']) ?></td>
	                </tr>
	                <tr>
	                    <th><?php echo text::getEscaped('seminar-appliesToShortPrograms') ?></th>
	                    <td><?php echo format::boolean($this->data->lateCharge['applies_to_single_days']) ?></td>
	                </tr>
	                <tr>
	                    <th><?php echo text::getEscaped('seminar-lateChargePercentage') ?></th>
	                    <td><?php echo $this->data->lateCharge['percentage'] ?> %</td>
	                </tr>
	            </tbody>
	        </table>
	        <?php
	        echo '</li>';
	    }
	    echo '</ul>';
}

// Total price
echo '<h2>' . text::getEscaped('registrationWizard.totalPrice') . '</h2>';
echo '<p class="description">' .  text::getEscaped('registrationWizard.totalPrice-desc') . '</p>';
echo '<span class="registrationPrice">' . format::price($this->data->preliminaryPrice, $this->data->priceGroup['currency_code']) . '</span>';

echo form::open('user/registrationWizard/next', array('id'=>'wizardForm'));
echo form::close();
